<template>
	<view class="p20">
		<u-navbar :isBack="false" :background="{background: '#0000'}" :border-bottom="false" />
		<view class="h60"></view>
		<view class="radius40 bg-fff p30 loginBoxShadow">
			<view class="flex mb30">
				<image :src="$config.shop_logo||''" class="h92 w92 radius20" mode=""></image>
				<view class="fs36 fw-600 ml24">{{type=="code"?'验证码':'密码'}}登录</view>
			</view>
			<u-form labelWidth="auto" :borderBottom="false">
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.mobile" maxlength="11" placeholder="请输入手机号码"></u-input>
					</view>
				</u-form-item>
				<u-form-item v-if="type=='password'">
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.login_pwd" type="password" placeholder="请输入密码"></u-input>
					</view>
				</u-form-item>
				<u-form-item v-else>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20 flex">
						<u-input v-model="form.code" class="flex1" placeholder="请输入验证码"></u-input>
						<tips :mobile="form.mobile" type="login" />
					</view>
				</u-form-item>
			</u-form>
			<view class="flex row-between mt30 mb40 color-666">
				<view class="" v-if="type=='password'" @click="type='code'">使用验证码登录</view>
				<view class="" v-else @click="type='password'">使用密码登录</view>
				<view class="" @click="$tool.jump('./forgetPwd')">忘记密码</view>
			</view>
 
			<u-button type="warning" class="radius20" ripple @click="submit">登录</u-button>
			<view class="flex row-center mt40 color-999">
				<view class="" @click="$tool.reUrl('./register')">注册</view>
			</view>

			<view class="flex fs24 mt20" @click="isLook=!isLook">
				<radio :checked="isLook" class="scale7 pe-none" :color="$zs"  />
				<view class="color-999">已阅读并同意</view>
				<view class="color-zs" @click.stop="$jump('/pages/public/text',{text:'master_pact',tit:'陪诊师协议'})">
					《陪诊师协议》</view>
				<view class="color-999">与</view>
				<view class="color-zs" @click.stop="$jump('/pages/public/text',{text:'privacy_pact',tit:'隐私政策'})">
					《隐私政策》
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLook:false,
				form: {
					mobile: '',
					login_pwd: '',
					code: ''
				},
				type: 'password', //code
			};
		},
		onLoad(e) {
			for (let key in this.form) e[key] && (this.form[key] = e[key])
		},
		methods: {
			submit() {
				if (!this.isLook) return this.$msg('请先同意协议')
				let api = '/master/login/login'
				if (this.type == 'code') api = '/master/login/codeLogin'
				this.$request(api, this.form).then(res => {
					this.$login_success(res,'back')
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		min-height: 100%;
		background: linear-gradient(145deg, rgba(253, 52, 52, 0.07) 0%, rgba(255, 255, 255, 0.1200) 35%, rgba(0, 212, 235, 0.10) 100%);
	}
</style>
